﻿using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using LibKetoan;

namespace Ketoan
{
	/// <summary>
	/// Summary description for frmTaouser.
	/// </summary>
	public class frmTaouser : System.Windows.Forms.Form
	{
		private System.Windows.Forms.NumericUpDown yyyy;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.Button butCancel;
		private System.Windows.Forms.Button butOk;
		private AccessData a;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public frmTaouser(AccessData acc)
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			a=acc;

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmTaouser));
			this.yyyy = new System.Windows.Forms.NumericUpDown();
			this.label2 = new System.Windows.Forms.Label();
			this.butCancel = new System.Windows.Forms.Button();
			this.butOk = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.yyyy)).BeginInit();
			this.SuspendLayout();
			// 
			// yyyy
			// 
			this.yyyy.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.yyyy.Location = new System.Drawing.Point(72, 16);
			this.yyyy.Maximum = new System.Decimal(new int[] {
																 3000,
																 0,
																 0,
																 0});
			this.yyyy.Minimum = new System.Decimal(new int[] {
																 2000,
																 0,
																 0,
																 0});
			this.yyyy.Name = "yyyy";
			this.yyyy.Size = new System.Drawing.Size(48, 21);
			this.yyyy.TabIndex = 1;
			this.yyyy.Value = new System.Decimal(new int[] {
															   2000,
															   0,
															   0,
															   0});
			this.yyyy.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tu_KeyDown);
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(24, 16);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(48, 23);
			this.label2.TabIndex = 0;
			this.label2.Text = "Năm :";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
			// 
			// butCancel
			// 
			this.butCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
			this.butCancel.Location = new System.Drawing.Point(83, 48);
			this.butCancel.Name = "butCancel";
			this.butCancel.Size = new System.Drawing.Size(60, 23);
			this.butCancel.TabIndex = 3;
			this.butCancel.Text = "Kết thúc";
			this.butCancel.Click += new System.EventHandler(this.butCancel_Click);
			// 
			// butOk
			// 
			this.butOk.Location = new System.Drawing.Point(18, 48);
			this.butOk.Name = "butOk";
			this.butOk.Size = new System.Drawing.Size(60, 23);
			this.butOk.TabIndex = 2;
			this.butOk.Text = "Tạo";
			this.butOk.Click += new System.EventHandler(this.butOk_Click);
			// 
			// frmTaouser
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.CancelButton = this.butCancel;
			this.ClientSize = new System.Drawing.Size(160, 85);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.butCancel,
																		  this.butOk,
																		  this.yyyy,
																		  this.label2});
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Name = "frmTaouser";
			this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
			this.Text = "Tạo lại số liệu";
			this.Load += new System.EventHandler(this.frmTaouser_Load);
			((System.ComponentModel.ISupportInitialize)(this.yyyy)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void tu_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (e.KeyCode==Keys.Enter) SendKeys.Send("{Tab}");
		}

		private void butCancel_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		private void butOk_Click(object sender, System.EventArgs e)
		{
			Cursor=Cursors.WaitCursor;
			if (a.bYyyy(yyyy.Value.ToString()))
			{
				a.modifyTable(yyyy.Value.ToString());
			}
			Cursor=Cursors.Default;
			butCancel.Focus();
		}

		private void frmTaouser_Load(object sender, System.EventArgs e)
		{	
			yyyy.Value=DateTime.Now.Year;
		}
	}
}
